package com.hk.core.autoconfigure.exception;

import com.hk.commons.util.JsonUtils;
import lombok.extern.slf4j.Slf4j;

/**
 * 当出现异常后的处理
 *
 * @author Kevin
 */
@Slf4j
public record LoggerUncaughtExceptionConsumer() implements UncaughtExceptionConsumer {

    @Override
    public void accept(ExceptionDetails exceptionDetails, Throwable t) {
        if (log.isErrorEnabled()) {
            log.error("Exception: {}", JsonUtils.serialize(exceptionDetails), t);
        }
    }
}
